The cross product of two vectors $\vec{a}\times\vec{b}$ gives a vector that is perpendicular to the plane of $\vec{a}$ and $\vec{b}$ with a length proportional to "how close $\vec{a}$ and $\vec{b}$ are to being perpendicular." In other words, the magnitude of the cross product tells you "how perpendicular" $\vec{a}$ and $\vec{b}$ are to each other. If $\vec{a}$ and $\vec{b}$ are parallel, then they are not perpendicular at all and the cross product is zero. If $\vec{a}$ and $\vec{b}$ are perpendicular then that is the "most perpendicular" that they can be and the cross product is a maximum.
Suppose that you have the vectors $\vec{a}=<0.5,2,0>$ and $\vec{b}=<2,0,0>$. What is the cross product of the vectors? In iVisual, use the function $\mathrm{cross}(a,b)$ where $a$ and $b$ are vectors. The function returns a vector that is teh cross product.
In [1]:
from __future__ import division, print_function
from ivisual import *
In [2]:
#define vectors
a=vector(0.5,2,0)
b=vector(2,0,0)
#calculate the cross product and print
aCrossB=cross(a,b)
print("a x b = ", aCrossB)
Cross products are not commutative. In fact,
$$\vec{a}\times\vec{b}=-\vec{b}\times\vec{a}$$So in iVisual, compute $\vec{b}\times\vec{a}$ and see if it's the negative of $\vec{a}\times\vec{b}$.
In [3]:
bCrossA=cross(b,a)
print("b x a = ", bCrossA)
In [6]:
#draw vectors
sw=0.05*mag(a)
aarrow=arrow(pos=(0,0,0), axis=a, color=color.red, shaftwidth=sw)
barrow=arrow(pos=(0,0,0), axis=b, color=color.blue, shaftwidth=sw)
aCrossBarrow=arrow(pos=(0,0,0), axis=aCrossB, color=color.cyan, shaftwidth=sw)
bCrossAarrow=arrow(pos=(0,0,0), axis=bCrossA, color=color.yellow, shaftwidth=sw)
Change the components of $\vec{a}$ and $\vec{b}$ and view the results. Check that it makes sense for special cases such as $\vec{a}$ and $\vec{b}$ perpendicular to each other and $\vec{a}$ and $\vec{b}$ parallel to teach other. Also try cases where $\vec{a}$ and $\vec{b}$ have z-components.
In [ ]: